#!/usr/bin/perl -w

my @RET = ();

# the adjusted close is the last column
my $col = 0;

for my $file ( @ARGV ) {
    die "error opening $file\n" unless open(IN,$file);
    my $v0=-1;
    my $row = 0;
    while(<IN>) {
	next unless ( $. % 20 );
	chomp;
	my (@value) = split /\,+/;
	my $v = $value[$#value];
	if ( $v0 < 0 ) {
	    $v0 = $v;
	    next;
	} else { 
	    $RET[$row][$col] = $v - $v0;
	    $v0 = $v;
	    ++$row;
	}
	# 1000 lines of data
	if ( $row >= 1000 ) {
	    close IN;
	    last;
	}
    }
    ++$col;
}

for ( my $r = 0; $r < 1000; ++$r ) {
    for ( my $c = 0; $c < $col; ++$c ) {
	print "$RET[$r][$c] ";
    }
    print "\n";
}

exit(0);
